# 我们把变量从内存中变成可存储或传输的过程称之为序列化
# 反之,我们称之为反序列化

import json

dict1 = {'name': 'zhangsan', 'age': 18}
print(dict1)
# with open('ss.txt', 'w+', encoding='utf-8') as f:
#     s = json.dumps(dict1)
#     print(type(s))
#     f.write(s)

# json 字符串,str

list1 = [1, 2, 3, 5, 6]
print(list1)
s = json.dumps(list1)
print(s)

str1 = '[1, 2, 3, 5, 6]'
list2 = json.loads(str1)
print(type(list2))
print(list2)

str2 = '{"name": "zhangsan", "age": 18}'
dict2 = json.loads(str2)
print(type(dict2))
print(dict2)
